/**
 * Created by Administrator on 15-10-10.
 */
window.onload=function(){
    var url=getUrl();
    var userid =getUserId();
    $(".log-xgmm").on("click",function(){

        var oldPwd=$("#olddPwd").val();
        var nPwd=$("#nPwd").val();
        var qPwd=$("#qPwd").val();
        if(oldPwd=="")
        {
            showToast("原密码不能为空~");
            return;
        }
        if(nPwd=="")
        {
            showToast("新密码不能为空~");
            return;
        }
        if(qPwd=="")
        {
            showToast("确认密码不能为空~");
            return;
        }
        if(oldPwd==nPwd)
        {
            showToast("新密码不能与原密码相同~");
            return;
        }
        if(nPwd!==qPwd)
        {
            showToast("两次输入的新密码不一致~");
            return;
        }

        $.jsonp({
            url: 'http://'+url+'/api/user/change_pwd',
            data: {oldPwd:oldPwd,nPwd:nPwd,qPwd:qPwd,userId:userid},
            callbackParameter: "callback",
            success: function (data, textStatus, xOptions) {
               showToast("修改成功");
               window.history.back();
            },
            error: function (xOptions,textStatus) {
            }
        });
    });
}